package com.monitor.common.response;

import java.util.HashMap;
import java.util.Map;

/**
 * CodeMsg    公共返回码Code基类
 *
 * @author worker
 * @date 2018 2/20/17 16:23
 * @since 2.0.0
 */
public class CodeMsg {
    /**
     * 接口版本号不存在
     */

    public static final int INVALID_VERSION = 101;
    /**
     * 请求成功
     */

    public static final int SUCCESS = 200;
    /**
     * 服务器异常
     */
    public static final int ERROR = 500;

    /**
     * 非法的参数
     */
    public static final int INVALID_PARAM   = 518;

    /**
     * 账号不存在
     */
    public static final int ACCOUNT_NOT_EXITS= 519;

    /**
     * 备份数据删除失败
     */
    public static final int BAK_DEL_FAILE= 520;

    //用户
    public static final int PASSWORD_ERROR=200001;
    public static final int USERNAME_EXIST = 200002;
    public static final int USERNAME_NOT_EXIST = 200003;
    public static final int INCONSISTENT_INPUT_TWICE = 200004;
    public static final int MOBILE_EXIST = 200005;

    //绿色通道
    public static final int TWO_QUERY_TIME = 300000;



    protected static final Map<Integer, String> MSG = new HashMap<Integer, String>();

    static {
        // 系统常用
        MSG.put(INVALID_VERSION, "接口版本号不存在.");
        MSG.put(SUCCESS, "请求成功.");
        MSG.put(INVALID_PARAM, "非法的请求参数.");

        // 账户相关
        MSG.put(ERROR, "服务器异常：%s");
        MSG.put(ACCOUNT_NOT_EXITS, "账户不存在.");
        MSG.put(BAK_DEL_FAILE, "备份数据删除失败.");

        //用户
        MSG.put(PASSWORD_ERROR, "密码错误");
        MSG.put(USERNAME_EXIST, "用户名已存在");
        MSG.put(MOBILE_EXIST, "手机号已存在");
        MSG.put(USERNAME_NOT_EXIST, "用户名不存在");
        MSG.put(INCONSISTENT_INPUT_TWICE, "两次输入的结果不一致");

        //绿色通道
        MSG.put(TWO_QUERY_TIME, "两次查询间隔不能小于%s秒");


    }


    public static String getMsg(int errcode) {
        return MSG.get(errcode);
    }

}
